// 常量定义

export const METHOD_GET = "GET";
export const METHOD_POST = "POST";
export const METHOD_HEAD = "HEAD";
export const METHOD_PUT = "PUT";
export const METHOD_PATCH = "PATCH";
export const METHOD_OPTIONS = "OPTIONS";
export const METHOD_DELETE = "DELETE";

// 激活状态
export const ACTIVE_STATUS_ACTIVED = 1;
export const ACTIVE_STATUS_INACTIVED = 0;

// 字段取舍
export const DATA_FILED_ENABLED = 1;
export const DATA_FILED_DISABLE = 0;

// 排序方向
export const DATA_SORT_ASC = 1;
export const DATA_SORT_DESC = -1;
export const DATA_SORT_ASC_LABEL = "asc";
export const DATA_SORT_DESC_LABEL = "desc";

export const DATA_SELECT_ALL = {
  id: 0,
  label: "all",
  title: "全部",
  color: "#eeeeee"
};

export const TABS_LABEL_ALL_LABEL = "all";

export const URL_DEV_MODE_LABEL = "dbg";

/**
 * 默认请求结构体
 * @type {{condition: {}, perpage: number, page: number, sort: {}, fields: {}}}
 */
export const REQUESTSTRUCT_DEFAULT = {
  condition: {},
  page: 1,
  perpage: 10,
  sort: {},
  fields: {}
};
/**
 * 默认查询结构
 * @type {{condition: {}, limit: number, skip: number, sort: {}, fields: {}}}
 */
export const DB_QUERYSTRUCT_DEFAULT = {
  condition: {},
  skip: 0,
  limit: 10,
  sort: {},
  projections: {}
};
/**
 * 结果数据结构
 * @type {{total: number, perpage: number, data: Array, page: number, sort: {}}}
 */
export const DB_RESULTSTRUCT_DEFAULT = {
  data: [],
  total: 0,
  page: 1,
  perpage: 10,
  offset: 0,
  sort: {}
};

// 默认过期时间间隔 3600*24*7
export const DEFAULT_EXPIRES_INTERVAL = 604800;
// 默认刷新时间间隔 3600*24*6
export const DEFAULT_REFRESH_INTERVAL = 518400;

// 两步验证状态
export const SETTINGS_ENVLABEL_PROD = "prod"; // 生产环境
export const SETTINGS_ENVLABEL_DEV = "dev"; // 开发环境
export const SETTINGS_ENVLABEL_TEST = "test"; // 测试环境
export const SETTINGS_ENVLABEL_STAGE = "stage"; // 预发布环境

export const SETTINGS_ENVLABEL_MAP = {
  [SETTINGS_ENVLABEL_PROD]: {
    id: SETTINGS_ENVLABEL_PROD,
    label: SETTINGS_ENVLABEL_PROD,
    title: "生产",
    color: "#2D8CF0",
    icon: "md-globe"
  },
  [SETTINGS_ENVLABEL_DEV]: {
    id: SETTINGS_ENVLABEL_DEV,
    label: SETTINGS_ENVLABEL_DEV,
    title: "开发",
    color: "#808695",
    icon: "md-construct"
  },
  [SETTINGS_ENVLABEL_TEST]: {
    id: SETTINGS_ENVLABEL_TEST,
    label: SETTINGS_ENVLABEL_TEST,
    title: "测试",
    color: "#19BE6B",
    icon: "md-flask"
  },
  [SETTINGS_ENVLABEL_STAGE]: {
    id: SETTINGS_ENVLABEL_STAGE,
    label: SETTINGS_ENVLABEL_STAGE,
    title: "预发布",
    color: "#BE03FC",
    icon: "md-flash"
  }
};

/* eslint-disable no-unused-vars */
/**
 * 默认系统配置
 * @type {{proxy: string, minimize2tray: boolean, showindock: boolean, headful: boolean, autostart: boolean, debugmode: boolean, deviceid: string, chromepath: string, authmainsite: boolean}}
 */
export const DEFAULT_CONF_SETTINGS = {
  deviceid: "",
  envlabel: SETTINGS_ENVLABEL_PROD,
  maxDownload: 3,
  maxProcess: 3,
  maxUpload: 3,
  autostart: true,
  autoupdate: true,
  usemockupapi: false,
  enableagent: true,
  debugmode: false
};

// 用户认证状态
export const USER_VERIFIEDSTATUS_UNKNOWN = 0; // 待确认
export const USER_VERIFIEDSTATUS_SUCCESS = 1; // 成功
export const USER_VERIFIEDSTATUS_FAILED = 2; // 失败

/**
 * 加密的字段列表
 * @type {string[]}
 */
export const ENCRYPTFIELDS_USER = [
  // "mfaSecret",
  "password"
];
export const ID_USER = "ID-USER";
/**
 * 用户基本信息
 * @type {{lastAccessIp: string, loginId: string, orgName: string, rememberPassword: boolean, isSuper: number, accessToken: string, orgId: number, lastAccessAt: number, password: string, lastVerifiedStatus: number, phone: string, isOps: number, orgCode: string, lastDeviceId: string, name: string, _id: string, id: number, lastVerifiedAt: number, email: string}}
 */
export const DEFAULT_DB_USER = {
  _id: ID_USER,
  lastVerifiedStatus: USER_VERIFIEDSTATUS_UNKNOWN,
  lastVerifiedAt: 0,
  id: 0,
  loginId: "",
  password: "",
  token: "",
  tokenIssueAt: 0,
  tokenNotBeforeAt: 0,
  tokenExpireAt: 0,
  tokenSubject: "",
  rememberMe: true,
  orgId: 0,
  orgName: "",
  orgCode: "",
  name: "",
  email: "",
  phone: "",
  isSuper: ACTIVE_STATUS_INACTIVED
};
/**
 * 客户基本信息
 * @type {{id: number, secret: string, key: string, token: string}}
 */
export const DEFAULT_CLIENT = {
  id: 0,
  key: "",
  secret: "",
  token: "",
  tokenIssueAt: 0
};

export const SERVICESETTINGS = {
  api: {
    local: {
      urlPrefix: "https://admin.laravel10.antdvue",
      api: {
        base: {
          check: "/status/check"
        },
        auth: {
          jwt_auth: "/auth/jwt/authorize",
        },
        user: {
          my_me: "/api/v1/My/getUserProfile"
        },
        amz: {
          seller: {

          }
        }
      }
    }
  }
};

// 错误码定义
export const CODE_NETWORK_TIME_OUT = 4000504; // 网络超时
// 客户有关
export const CODE_CLIENT_AUTH_FAILED = 4001001; // 认证失败
export const CODE_CLIENT_AUTHLOGIN_REQUIRED = 4001401; // 请先登录认证
export const CODE_CLIENT_BASEINFO_REQUIRED = 4001002; // 基本信息必填
export const CODE_CLIENT_AUTH_CAPTCHA_REQUIRED = 4001004; // 需要人机验证码
export const CODE_CLIENT_AUTH_AUTHINFO_ERROR = 4001005; // 认证失败
export const CODE_CLIENT_AUTH_AUTHINFO_RETRY_LIMIT_EXCEED = 4001006; // 重试次数超限
export const CODE_CLIENT_AUTH_AUTHINFO_UNKNOWN = 4001007; // 登录表单问题
export const CODE_CLIENT_AUTH_AUTHINFO_AUTOSUBMIT_FAILED = 4001008; // 自动认证失败
export const CODE_CLIENT_AUTH_MFA_UNKNOWN = 4001009; // MFA表单问题
export const CODE_CLIENT_AUTH_MFA_ERROR = 4001010; // MFA认证失败
export const CODE_CLIENT_AUTH_MFA_RETRY_LIMIT_EXCEED = 4001011; // 重试次数超限
export const CODE_CLIENT_AUTH_NEED_REG = 4001012; // 用户需要注册
export const CODE_CLIENT_AUTH_MFA_BIND_ERROR = 4001013; // MFA绑定失败
export const CODE_CLIENT_IPCHANGE_BLOCKED = 4001014; // ip变更已阻止
export const CODE_CLIENT_PARSE_ERROR = 4001015; // 页面解析失败

// 用户有关
export const CODE_USER_AUTH_FAILED = 4000001; // 认证失败
export const CODE_USER_AUTHLOGIN_REQUIRED = 4000401; // 请先登录认证
export const CODE_USER_BASEINFO_REQUIRED = 4000002; // 基本信息必填
export const CODE_USER_AUTH_CAPTCHA_REQUIRED = 4000004; // 需要人机验证码
export const CODE_USER_AUTH_AUTHINFO_ERROR = 4000005; // 认证失败
export const CODE_USER_AUTH_AUTHINFO_RETRY_LIMIT_EXCEED = 4000006; // 重试次数超限
export const CODE_USER_AUTH_AUTHINFO_UNKNOWN = 4000007; // 登录表单问题
export const CODE_USER_AUTH_AUTHINFO_AUTOSUBMIT_FAILED = 4000008; // 自动认证失败
export const CODE_USER_AUTH_MFA_UNKNOWN = 4000009; // MFA表单问题
export const CODE_USER_AUTH_MFA_ERROR = 4000010; // MFA认证失败
export const CODE_USER_AUTH_MFA_RETRY_LIMIT_EXCEED = 4000011; // 重试次数超限
export const CODE_USER_AUTH_NEED_REG = 4000012; // 用户需要注册
export const CODE_USER_AUTH_MFA_BIND_ERROR = 4000013; // MFA绑定失败
export const CODE_USER_IPCHANGE_BLOCKED = 4000014; // ip变更已阻止
export const CODE_USER_PARSE_ERROR = 4000015; // 页面解析失败
